#define  _CRT_SECURE_NO_WARNINGS 1
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>

void Swap(int* a, int* b)
{
	int temp = *a;
	*a = *b;
	*b = temp;
}



void InsertSort(int* a, int n)
{
	assert(a);
	for (int i = 0; i < n - 1; i++)
	{
		int end = i + 1;
		int tmp = a[end];
		while (end > 0)
		{
			if (a[end] < a[i])
			{
				a[end] = a[i];
				end--;
			}
			else
			{
				break;
			}
		}
		a[end] = tmp;
	}

}

void print(int* a, int n)
{
	for (int i = 0; i < n; i++)
	{
		printf("%d ", a[i]);
	}
	printf("\n");
}

int main()
{
	int a[] = { 1,2,12,6,8,44,67,-1,0 };
	int len = sizeof(a) / sizeof(a[0]);
	InsertSort(a, len);
	print(a, len);

}